<html>
<head><meta charset="utf-8"><title>Why doesn&#x27;t cargo allow multiple versions here? · t-cargo · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/246057-t-cargo/index.html">t-cargo</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/246057-t-cargo/topic/Why.20doesn&#x27;t.20cargo.20allow.20multiple.20versions.20here.3F.html">Why doesn&#x27;t cargo allow multiple versions here?</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="228989782"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/246057-t-cargo/topic/Why%20doesn%27t%20cargo%20allow%20multiple%20versions%20here%3F/near/228989782" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/246057-t-cargo/topic/Why.20doesn&#x27;t.20cargo.20allow.20multiple.20versions.20here.3F.html#228989782">(Mar 05 2021 at 17:14)</a>:</h4>
<p>Mostly just curious, I don't <em>want</em> the duplicate versions, but - why doesn't cargo build two different versions of <code>miow</code> instead of giving up?</p>
<div class="codehilite"><pre><span></span><code>error: failed to select a version for `miow`.
    ... required by package `mio v0.7.6`
    ... which is depended on by `tokio v1.0.1`
    ... which is depended on by `rustwide v0.12.0 (https://github.com/jyn514/rustwide?branch=rustdoc-binary#dd62ea1c)`
    ... which is depended on by `docs-rs v0.6.0 (/home/joshua/src/rust/docs.rs)`
versions that meet the requirements `^0.3.6` are: 0.3.6

all possible versions conflict with previously selected packages.

  previously selected package `miow v0.3.3`
    ... which is depended on by `mio-named-pipes v0.1.6`
    ... which is depended on by `tokio v0.2.22`
    ... which is depended on by `docs-rs v0.6.0 (/home/joshua/src/rust/docs.rs)`

failed to select a version for `miow` which could resolve this conflict
</code></pre></div>



<a name="228990424"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/246057-t-cargo/topic/Why%20doesn%27t%20cargo%20allow%20multiple%20versions%20here%3F/near/228990424" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bjorn3 <a href="https://rust-lang.github.io/zulip_archive/stream/246057-t-cargo/topic/Why.20doesn&#x27;t.20cargo.20allow.20multiple.20versions.20here.3F.html#228990424">(Mar 05 2021 at 17:18)</a>:</h4>
<p>0.3.3 and 0.3.6 are semver compatible. Normally only one semver compatible version of a crate would be built. If there are multiple semver compatible versions, it is ambiguous which crate should get which version as dependency.</p>



<a name="228990568"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/246057-t-cargo/topic/Why%20doesn%27t%20cargo%20allow%20multiple%20versions%20here%3F/near/228990568" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/246057-t-cargo/topic/Why.20doesn&#x27;t.20cargo.20allow.20multiple.20versions.20here.3F.html#228990568">(Mar 05 2021 at 17:19)</a>:</h4>
<p>I would expect it to build the latest available version</p>



<a name="228990585"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/246057-t-cargo/topic/Why%20doesn%27t%20cargo%20allow%20multiple%20versions%20here%3F/near/228990585" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/246057-t-cargo/topic/Why.20doesn&#x27;t.20cargo.20allow.20multiple.20versions.20here.3F.html#228990585">(Mar 05 2021 at 17:19)</a>:</h4>
<p>otherwise <em>all</em> requirements would be ambiguous</p>



<a name="228990724"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/246057-t-cargo/topic/Why%20doesn%27t%20cargo%20allow%20multiple%20versions%20here%3F/near/228990724" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Eh2406 <a href="https://rust-lang.github.io/zulip_archive/stream/246057-t-cargo/topic/Why.20doesn&#x27;t.20cargo.20allow.20multiple.20versions.20here.3F.html#228990724">(Mar 05 2021 at 17:20)</a>:</h4>
<p><code>mio-named-pipes</code> must not work with <code>0.3.6</code></p>



<a name="228991499"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/246057-t-cargo/topic/Why%20doesn%27t%20cargo%20allow%20multiple%20versions%20here%3F/near/228991499" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/246057-t-cargo/topic/Why.20doesn&#x27;t.20cargo.20allow.20multiple.20versions.20here.3F.html#228991499">(Mar 05 2021 at 17:25)</a>:</h4>
<p>yeah it looks like someone pinned =0.3.3 while someone else required ^0.3.6 and then the world exploded because they're supposedly semver compatible.</p>
<p>so either the person requesting =0.3.3 needs to fix their stuff, or <code>miow</code> itself broke semver on accident.</p>



<a name="228992000"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/246057-t-cargo/topic/Why%20doesn%27t%20cargo%20allow%20multiple%20versions%20here%3F/near/228992000" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/246057-t-cargo/topic/Why.20doesn&#x27;t.20cargo.20allow.20multiple.20versions.20here.3F.html#228992000">(Mar 05 2021 at 17:28)</a>:</h4>
<p>that makes sense, thanks :)</p>



<a name="228992053"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/246057-t-cargo/topic/Why%20doesn%27t%20cargo%20allow%20multiple%20versions%20here%3F/near/228992053" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/246057-t-cargo/topic/Why.20doesn&#x27;t.20cargo.20allow.20multiple.20versions.20here.3F.html#228992053">(Mar 05 2021 at 17:28)</a>:</h4>
<p>(I'm not going to go after them because I want to upgrade to tokio 1.0 at some point, and I'd rather wait than go back above 500 dependencies)</p>



<a name="228992134"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/246057-t-cargo/topic/Why%20doesn%27t%20cargo%20allow%20multiple%20versions%20here%3F/near/228992134" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Eh2406 <a href="https://rust-lang.github.io/zulip_archive/stream/246057-t-cargo/topic/Why.20doesn&#x27;t.20cargo.20allow.20multiple.20versions.20here.3F.html#228992134">(Mar 05 2021 at 17:29)</a>:</h4>
<p>And Yes Cargos error message should explain that better!</p>



<a name="228992302"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/246057-t-cargo/topic/Why%20doesn%27t%20cargo%20allow%20multiple%20versions%20here%3F/near/228992302" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Steven Fackler <a href="https://rust-lang.github.io/zulip_archive/stream/246057-t-cargo/topic/Why.20doesn&#x27;t.20cargo.20allow.20multiple.20versions.20here.3F.html#228992302">(Mar 05 2021 at 17:30)</a>:</h4>
<p>mio-named-pipes has totally normal dependency constraints, so it's not that: <a href="https://docs.rs/crate/mio-named-pipes/0.1.6/source/Cargo.toml.orig">https://docs.rs/crate/mio-named-pipes/0.1.6/source/Cargo.toml.orig</a></p>



<a name="228992654"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/246057-t-cargo/topic/Why%20doesn%27t%20cargo%20allow%20multiple%20versions%20here%3F/near/228992654" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Eh2406 <a href="https://rust-lang.github.io/zulip_archive/stream/246057-t-cargo/topic/Why.20doesn&#x27;t.20cargo.20allow.20multiple.20versions.20here.3F.html#228992654">(Mar 05 2021 at 17:32)</a>:</h4>
<p>edit: Cargos error message needs to explain what the hell is going on!<br>
But don't hold your breath I've been working on it for years.</p>



<a name="228993283"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/246057-t-cargo/topic/Why%20doesn%27t%20cargo%20allow%20multiple%20versions%20here%3F/near/228993283" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/246057-t-cargo/topic/Why.20doesn&#x27;t.20cargo.20allow.20multiple.20versions.20here.3F.html#228993283">(Mar 05 2021 at 17:36)</a>:</h4>
<p>if someone wants to replicate locally, apply this patch to <a href="http://docs.rs">docs.rs</a>:</p>
<div class="codehilite" data-code-language="Diff"><pre><span></span><code><span class="gh">diff --git a/Cargo.toml b/Cargo.toml</span>
<span class="gh">index 06b12e74..2d375287 100644</span>
<span class="gd">--- a/Cargo.toml</span>
<span class="gi">+++ b/Cargo.toml</span>
<span class="gu">@@ -43,7 +43,7 @@ schemamama = "0.3"</span>
 schemamama_postgres = "0.3"
 systemstat = "0.1.4"
 prometheus = { version = "0.10.0", default-features = false }
<span class="gd">-rustwide = "0.11"</span>
<span class="gi">+rustwide = { git = "https://github.com/jyn514/rustwide", branch = "rustdoc-binary" }</span>
 mime_guess = "2"
 dotenv = "0.15"
 zstd = "0.5"
</code></pre></div>



<a name="228993339"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/246057-t-cargo/topic/Why%20doesn%27t%20cargo%20allow%20multiple%20versions%20here%3F/near/228993339" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/246057-t-cargo/topic/Why.20doesn&#x27;t.20cargo.20allow.20multiple.20versions.20here.3F.html#228993339">(Mar 05 2021 at 17:36)</a>:</h4>
<p>strangely <code>rustwide = "0.12"</code> works fine</p>



<a name="229001479"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/246057-t-cargo/topic/Why%20doesn%27t%20cargo%20allow%20multiple%20versions%20here%3F/near/229001479" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> hyd-dev <a href="https://rust-lang.github.io/zulip_archive/stream/246057-t-cargo/topic/Why.20doesn&#x27;t.20cargo.20allow.20multiple.20versions.20here.3F.html#229001479">(Mar 05 2021 at 18:29)</a>:</h4>
<p>The v0.3.3 of <code>miow</code> seems coming from the lock file of <code>docs.rs</code>: <a href="https://github.com/rust-lang/docs.rs/blob/da1f36263ff70c02b119a9582c1228b08bd233f2/Cargo.lock#L1808">https://github.com/rust-lang/docs.rs/blob/da1f36263ff70c02b119a9582c1228b08bd233f2/Cargo.lock#L1808</a></p>
<p>Looks like for some reasons Cargo refused to update <code>miow</code>. A <em>full</em> update by <code>cargo update</code> works, and the resulting <code>Cargo.lock</code> does not contain <code>miow</code> 0.3.3.</p>
<p>Also <code>once_cell</code> seems is affected too -- if I update <code>miow</code> to 0.3.6 by <code>cargo update -p miow:0.3.3</code> before applying the patch, it fails with this:</p>
<div class="codehilite"><pre><span></span><code>error: failed to select a version for `once_cell`.
    ... required by package `tokio v1.0.1`
    ... which is depended on by `rustwide v0.12.0 (https://github.com/jyn514/rustwide?branch=rustdoc-binary#60de5301)`
    ... which is depended on by `docs-rs v0.6.0 (/home/hyd/code/docs.rs)`
versions that meet the requirements `^1.5.2` are: 1.7.2, 1.7.1, 1.7.0, 1.6.0, 1.5.2

all possible versions conflict with previously selected packages.

  previously selected package `once_cell v1.4.0`
    ... which is depended on by `badge v0.3.0 (/home/hyd/code/docs.rs/crates/badge)`
    ... which is depended on by `docs-rs v0.6.0 (/home/hyd/code/docs.rs)`

failed to select a version for `once_cell` which could resolve this conflict
</code></pre></div>
<p>But if I update both of them by <code>cargo update -p miow:0.3.3 -p once_cell:1.4.0</code> before or after applying the patch, Cargo is extremely happy. The resulting lock file does not contain <code>miow</code> 0.3.3 either.</p>
<p><span aria-label="shrug" class="emoji emoji-1f937" role="img" title="shrug">:shrug:</span></p>



<a name="229001506"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/246057-t-cargo/topic/Why%20doesn%27t%20cargo%20allow%20multiple%20versions%20here%3F/near/229001506" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Eric Huss <a href="https://rust-lang.github.io/zulip_archive/stream/246057-t-cargo/topic/Why.20doesn&#x27;t.20cargo.20allow.20multiple.20versions.20here.3F.html#229001506">(Mar 05 2021 at 18:29)</a>:</h4>
<p><span class="user-mention" data-user-id="120179">@Eh2406</span> I see what is happening here.  <a href="https://github.com/rust-lang/cargo/blob/c69409658a1f19452b784f675984e46da752a75b/src/cargo/ops/resolve.rs#L567-L586">These lines</a> are the relevant section.</p>



<a name="229001567"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/246057-t-cargo/topic/Why%20doesn%27t%20cargo%20allow%20multiple%20versions%20here%3F/near/229001567" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Eric Huss <a href="https://rust-lang.github.io/zulip_archive/stream/246057-t-cargo/topic/Why.20doesn&#x27;t.20cargo.20allow.20multiple.20versions.20here.3F.html#229001567">(Mar 05 2021 at 18:29)</a>:</h4>
<p>When adding the git dependency, it doesn't know it needs to poison the <a href="http://crates.io">crates.io</a> source.</p>



<a name="229001617"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/246057-t-cargo/topic/Why%20doesn%27t%20cargo%20allow%20multiple%20versions%20here%3F/near/229001617" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Eric Huss <a href="https://rust-lang.github.io/zulip_archive/stream/246057-t-cargo/topic/Why.20doesn&#x27;t.20cargo.20allow.20multiple.20versions.20here.3F.html#229001617">(Mar 05 2021 at 18:30)</a>:</h4>
<p>Not sure how to fix that, that is a very delicate section of code.</p>



<a name="229002679"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/246057-t-cargo/topic/Why%20doesn%27t%20cargo%20allow%20multiple%20versions%20here%3F/near/229002679" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Eric Huss <a href="https://rust-lang.github.io/zulip_archive/stream/246057-t-cargo/topic/Why.20doesn&#x27;t.20cargo.20allow.20multiple.20versions.20here.3F.html#229002679">(Mar 05 2021 at 18:36)</a>:</h4>
<p><span class="user-mention" data-user-id="232545">@Joshua Nelson</span> A workaround is to run <code>cargo update -p rustwide -p once_cell</code>.  The issue is that Cargo doesn't want to invalidate transitive dependencies, so they stay "locked" to the version in Cargo.lock.  However, rustwide 0.12 brings in some new requirements that cause a conflict.  Cargo should be invalidating those, but when changing the source, it doesn't.</p>



<a name="229006151"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/246057-t-cargo/topic/Why%20doesn%27t%20cargo%20allow%20multiple%20versions%20here%3F/near/229006151" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Eric Huss <a href="https://rust-lang.github.io/zulip_archive/stream/246057-t-cargo/topic/Why.20doesn&#x27;t.20cargo.20allow.20multiple.20versions.20here.3F.html#229006151">(Mar 05 2021 at 18:59)</a>:</h4>
<p>Filed <a href="https://github.com/rust-lang/cargo/issues/9240">https://github.com/rust-lang/cargo/issues/9240</a></p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>